%-----------------------------------------------------------------------------------------------------------------------------------
% solves for the slip profile for a desired shear rate profile and given wall deflection profile
%-----------------------------------------------------------------------------------------------------------------------------------
function shearsoln = shearsolve(shearsystem,simul)

%-----------------------------------------------------------------------------------------------------------------------------------
%	loading system variables
	struct2vars(shearsystem);
%	loading simulation variables
	struct2vars(simul);
%-----------------------------------------------------------------------------------------------------------------------------------

%-----------------------------------------------------------------------------------------------------------------------------------
	% system variables
	L =				L1;
	bet =			Delt/L;
	gamm =			H/L;
	kapp =			bslipper/L;
	ph0 =			((bet*kapp)/(gamm^3))*((muvisc*Q)/((min(lambd+2*G))*L^2));
%-----------------------------------------------------------------------------------------------------------------------------------

%-----------------------------------------------------------------------------------------------------------------------------------
%	obtaining slip profile
	bslip =			zeros(1,nx);
	if (modeshear == 0)
		for ix = 1:nx
			bslip(ix) =	-((gamm*L)/4)*(1-((ph0*h(ix))/gamm))* ...
						(1-6/((1-((ph0*h(ix))/gamm))^2*dvxdy(ix)));
		end
	elseif (modeshear == 1)
		for ix = 1:nx
			bslip(ix) =	-((gamm*L)/4)*(1-((ph0*h(ix))/gamm))* ...
						(1+3/((1-((ph0*h(ix))/gamm))^2*dvxdy(ix)+3));
		end
	else
		for ix = 1:nx
			bslip(ix) =	-((gamm*L)/4)*(1-((ph0*h(ix))/gamm))* ...
						(1-(3/2)/((1-((ph0*h(ix))/gamm))^2*dvxdy(ix)+(3/2)));
		end
	end		
%-----------------------------------------------------------------------------------------------------------------------------------
	
%-----------------------------------------------------------------------------------------------------------------------------------
%	feeding variables to output struct
	shearsoln.bslip =	bslip;
%-----------------------------------------------------------------------------------------------------------------------------------
end